package web.api.global.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import web.api.global.message.LoginApiRequest;
import web.api.global.message.RegisterApiRequest;
import web.api.global.message.TokenApiResponse;

import javax.validation.Valid;

/**
 * @author Jin Zheng
 * @since 1.0 2022-01-06
 */

public interface IndexController {

	@Operation(operationId = "主页", summary = "用户注册",
			description = "用户注册需要手机号码，名称，密码等属性", tags = "主页")
	@ApiResponses({
			@ApiResponse(responseCode = "204", description = "No Content"),
			@ApiResponse(responseCode = "400", ref = "response400")
	})
	@PostMapping("/register")
	ResponseEntity<Void> register(@RequestBody @Valid RegisterApiRequest request);

	@Operation(operationId = "主页", summary = "用户登录",
			description = "用户登录需要手机号码，密码等属性", tags = "主页")
	@ApiResponses({
			@ApiResponse(responseCode = "200", description = "OK",
					content=@Content(schema = @Schema(implementation = TokenApiResponse.class))),
			@ApiResponse(responseCode = "400", ref = "response400")
	})
	@PostMapping("/login")
	TokenApiResponse login(@RequestBody @Valid LoginApiRequest request);

}
